package com.travel.rabbit.service.impl;

import com.travel.rabbit.entity.UserSettings;
import com.travel.rabbit.dao.UserSettingsMapper;
import com.travel.rabbit.service.UserSettingsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (UserSettings)表服务实现类
 *
 * @author makejava
 * @since 2023-06-20 15:14:36
 */
@Service("userSettingsService")
public class UserSettingsServiceImpl implements UserSettingsService {
    @Resource
    private UserSettingsMapper userSettingsDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public UserSettings queryById(Integer id) {
        return this.userSettingsDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<UserSettings> queryAllByLimit(int offset, int limit) {
        return this.userSettingsDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param userSettings 实例对象
     * @return 实例对象
     */
    @Override
    public UserSettings insert(UserSettings userSettings) {
        this.userSettingsDao.insert(userSettings);
        return userSettings;
    }

    /**
     * 修改数据
     *
     * @param userSettings 实例对象
     * @return 实例对象
     */
    @Override
    public UserSettings update(UserSettings userSettings) {
        this.userSettingsDao.update(userSettings);
        return this.queryById(userSettings.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.userSettingsDao.deleteById(id) > 0;
    }
}